package com.briup.app02.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.briup.app02.bean.BasePrivilege;
import com.briup.app02.bean.BasePrivilegeExample;
import com.briup.app02.dao.BasePrivilegeMapper;
import com.briup.app02.service.IBasePrivilegeService;

@Service
public class BasePrivilegeServiceImpl implements IBasePrivilegeService{
	@Autowired
	private BasePrivilegeMapper baseprivilegemapper;

	@Override
	public List<BasePrivilege> findAll() {
		BasePrivilegeExample example = new BasePrivilegeExample();
		return baseprivilegemapper.selectByExample(example);
	}

	@Override
	public List<BasePrivilege> findByParentId(Long parentId) {
		BasePrivilegeExample example = new BasePrivilegeExample();
		BasePrivilegeExample.Criteria criteria = example.createCriteria();
		if(parentId != null) {
			criteria.andParentIdEqualTo(parentId);
		}
		return baseprivilegemapper.selectByExample(example);
	}

	@Override
	public void saveOrUpdate(BasePrivilege baseprivilege) {
		if(baseprivilege.getId() == null) {
			baseprivilegemapper.insert(baseprivilege);
		} else {
			baseprivilegemapper.updateByPrimaryKey(baseprivilege);
		}
	}

	@Override
	public void deleteById(long id) {
		baseprivilegemapper.deleteByPrimaryKey(id);
		
	}
	
}
